import axios from "axios";
import { Toast } from "vant";
const instance = axios.create({
  baseURL: "http://121.199.64.192:3000/api/login",
  // baseURL: "http://127.0.0.1:3000/api/login",

  timeout: 3000,
});
const http = {
  get(api, params) {
    return new Promise((resolve) => {
      return instance
        .get(api, { params: params })
        .then((response) => {
          resolve(response.data);
        })
        .catch((error) => {
          Toast(error);
        });
    });
  },

  // 登录注册
  post(api, params) {
    return new Promise((resolve) => {
      return instance
        .post(api, params)
        .then((response) => {
          resolve(response.data);
        })
        .catch((error) => {
          Toast(error);
        });
    });
  },
};
export default http;
